#include "qcolorgroupeditor.h"

#include "qcolorgroupdialog.h"

#include "../../shared/property/qabstractproperty.h"
#include "../undocommand/qpropertychangedundocommand.h"
#include "../../shared/host/qabstracthost.h"
#include "../../shared/qpropertyfactory.h"

QColorGroupEditor::QColorGroupEditor(QAbstractProperty *property, QUndoStack *stack, QWidget *parent):
    QButtonCommonEditor(property,stack,parent)
{
    m_undo_stack=stack;
}

void QColorGroupEditor::btn_clicked()
{
    QColorGroupDialog dlg(m_property->get_value(),this);

    dlg.exec();

    QVariant value=dlg.get_value();

    if(value.isValid())
    {
        if(!m_property->cmp(value))
        {
            QPropertyChangedUndoCommand *cmd=new QPropertyChangedUndoCommand(
                        m_property->get_host()->get_uuid(),
                        m_property->get_name(),
                        m_property->get_value(),value);
            m_undo_stack->push(cmd);
        }
    }
}


qRegisterPropertyEditor(Color_Group,QColorGroupEditor)
